<template>
	<view class="content">
		<view class='page_teacher' v-if="show_page==1">
			<view class='top_wrap' id="top1" :class="top_height==0?'top_wrap_posit':''">
				<view class="top_box">
					<view class='top_bg_box'>
						<view class='top_bg' :class="[statusBarHeight>20?'top_bg_wrap':'',scroll==0?'top_bg_height':'']"></view>
					</view>
					<view class="top_bar_wrap">
						<topBar 
							:topStyle="topStyle"
							:address="address"
							:showPage="show_page"
							@chooseLocation="choose_location"
							@navSearch="nav_search"
						>
						</topBar>
						<view class='banner_box' id="banner" :style="{height:scroll_height}">
							 <swiper class='swiper' :autoplay="true" :circular="true" :interval="3000" :duration="1000" :current="current_index" @change="swiperChange">
							 	<swiper-item class='item' v-for="(item,index) in banners" :key="index">
							 		<image class='img' :src="item.imgUrl" mode="aspectFill" @click="jump_view(index)"></image>
							 	</swiper-item>
							 </swiper>
							 <view class="indication">
								<block v-for="(item,index) in banners" :key="index">
									<view class="spot" :class="current_index==index?' active':''"></view>
								</block>
							</view>
						 </view>
						 <view class="nav_bar" :class="scroll==0?'nav_pad':''">
							 <view class='bar_wrap'>
								 <image class='bar_img' :src="bar_index==0?'/static/icon3.png':'/static/icon4.png'" @click="choose_nav(0)"></image>
								 <view class='bar_text' :class="bar_index==1?'active':''" @click="choose_nav(1)">附近</view>
							 </view>
							 <view class='btn_wrap'>
								 <view class='btn' @click="nav_object()"><view class='text'>求职意向</view><image class='icon' src="/static/icon5.png"></image></view>
								 <view class='btn' @click="nav_screen()"><view class='text'>筛选</view><image class='icon' src="/static/icon5.png"></image></view>
							 </view>
						 </view>
					</view>
				</view>
			</view>
			<view class='job_list' :style="{paddingTop:top_height+'px'}">
				<jobItem :jobs="jobs" v-if="jobs.length>0"></jobItem>
				<view class='no_cont' v-if="show_nav">
					<view class="no_box">
					    <view class='title'>积极的人生，才有更好的收获!</view>
					</view>
				</view>
			</view>
		</view>
		<view class='page_mech' v-if="show_page==2">
			<view class='top_wrap' id="top2" :class="top_height==0?'top_wrap_posit':''">
				<view class='top_box'>
					<topBar 
						:topStyle="topStyle"
						:address="address"
						:showPage="show_page"
						@chooseLocation="choose_location"
						@navSearch="nav_search"
					>
					</topBar>
				</view>
				<checkDem @checkDem="check_dem"></checkDem>
			</view>
			<view class='teach_list' :style="{paddingTop:top_height+'px'}">
				<teacherItem :teachers="teachers" v-if="teachers.length>0"></teacherItem>
				<view class='no_cont' style='margin-top: 160rpx;' v-if="show_nav">
					<view class="no_box">
					    <view class='title'>积极的人生，才有更好的收获!</view>
					</view>
				</view>
			</view>
			<screen
				:showMask="show_mask"
				:screens="screens"
				:screenIndex="screenIndex"
				:topHeight="top_height"
				@closeMask="close_mask"
				@checkScreen="check_screen"
				@deleteScreen="delete_screen"
				@confirmScreen="confirm_screen"
			>
			</screen>
		</view>
	</view>
</template>

<script>
	import JobItem from "../../components/jobItem.vue"
	import TopBar from "../../components/topBar.vue"
	import TeacherItem from "../../components/teacherItem.vue"
	import Screen from "../../components/screen.vue"
	import CheckDem from "../../components/checkDem.vue"
	import home from "../../api/home.js"
	import config from "../../api/config.js"
	import util from "../../utils/util.js"
	import qqmapsdk from "../../utils/qqmap-wx-jssdk.js"
	import permision from '../../js_sdk/wa-permission/permission.js';
	import api from "../../api/api.js"
	export default {
		data() {
			return {
				windowHeight: '',
				windowWidth: '',
				top_height: '',
				padding_height: '',
				address: '佛山市',
				addressInfo:{},
				statusBarHeight: '',
				topStyle: '',
				banners: [],
				current_index: 0,
				bar_index: 0,
				jobs: [],
				teachers: [],
				show_mask: false,
				check_index: '',
				screenIndex: '',
				screens: '',
				isRange: 1,
				job_name: '',
				positionId: -1,
				positionChildId: -1,
				educats:[],
				educat_id: '',
				educat_index: -2,
				expers: [],
				yearMax: '',
				yearMin: '',
				exper_index: -2,
				wages: [],
				salaryRangeMax: '',
				salaryRangeMin: '',
				wage_index: -2,
				show_page: 1,
				currentPage: 1,
				pageSize: 20,
				hasMoreData: true,
				latitude: 22.814250349,
				longitude: 113.266816674,
				minimumEducationId: '',
				workExperienceId: '',
				positionNature: '',
				sidx: "create_time",
				order: "desc",
				screening: false,
				user_address: '',
				login: false,
				jobObjectCitys: '',
				prop_index: -2,
				show_nav: false,
				userinfo: '',
				banner_height: 0,
				scroll_height: 'auto',
				scroll: '',
				count: 0
			}
		},
		onLoad() {
			var that=this;
			var sysinfo = wx.getSystemInfoSync(),statusBarHeight=sysinfo.statusBarHeight;
			that.windowHeight=sysinfo.windowHeight;
			that.windowWidth=sysinfo.windowWidth;
			that.statusBarHeight=statusBarHeight;
			that.topStyle='height:'+statusBarHeight+'px';
			// 定位
			const showPageNum = uni.getStorageSync('identityNum')
			// #ifdef MP-WEIXIN
			if(this.show_page==showPageNum||!showPageNum){
				that.get_user_location();
			}
			// #endif
			// #ifdef APP-PLUS
			uni.getSystemInfo({
			    success: function (res) {
					const platform = res.platform
					if(platform=='ios'){
						that.requestIosPermission()
					}
					if(platform=='android'){
						that.requestAndroidPermission()
					}
				},
			})
			uni.$on('addressInfo', that.addressUpdate)
			// #endif
		},
		onReady() {
			// #ifdef H5
			var that=this;
			that.watch_height();
			// #endif
		},
		onUnload() {
			const that = this
			// #ifdef APP-PLUS
			 uni.$off('addressInfo', that.addressUpdate)
			 // #endif
		},
		onShow() {
			var that=this;
			const showPageNum = uni.getStorageSync('identityNum')
			if(showPageNum){
				this.show_page = showPageNum?showPageNum:1
				that.login=true;
			}else{
				this.login=false
				uni.removeStorageSync('unionId')
				uni.removeStorageSync('userinfo')
				uni.removeStorageSync('token')
				uni.removeStorageSync('login_info')
			}
			if(that.screening){
				that.screening=false;
				that.show_nav=false;
				that.currentPage=1;
				if(that.show_page==1){
					that.jobs=[];
					that.get_job_list();
				}else{
					that.teachers=[];
					that.get_teacher_list();
				}
			}
			// if(uni.getStorageInfoSync("userinfo")&&that.login){
			// 	that.get_org_list();
			// }
			if(uni.getStorageSync("change_jobObject")){
				uni.removeStorageSync("change_jobObject")
				this.show_nav=false;
				that.currentPage=1;
				that.jobs=[]
				that.get_job_intention()
			}
			// #ifdef APP-PLUS
			uni.getSystemInfo({
			    success: function (res) {
					// console.log(res)
					const platform = res.platform
					if(platform=='ios'){
						// console.log(uni.getStorageSync('isLocation'),permision.judgeIosPermission("location"))
						const isLocation = permision.judgeIosPermission("location")?1:0;
						const is_location = Number(uni.getStorageSync('isLocation'));
						if(is_location==0&&is_location!=isLocation){
							uni.setStorageSync('isLocation',isLocation);
							// 请求数据
							that.watch_height();
							that.get_address_sdk(that.latitude,that.longitude,1)
						}
					}
					if(platform=='android'){
						// console.log(uni.getStorageSync('isLocation'),permision.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION'))
						var result = permision.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION');
						var is_location = uni.getStorageSync('isLocation');
						if(is_location==0&&is_location!=result){
							uni.setStorageSync('isLocation',result);
							// 请求数据
							that.watch_height();
							that.get_address_sdk(that.latitude,that.longitude,1)
						}
					}
				},
			})
			// #endif
		},
		// 下拉刷新
		onPullDownRefresh(){
			var that=this;
			that.show_nav=false;
			that.currentPage=1;
			that.top_height=0;
			// console.log(that.banner_height,that.scroll_height)
		    // 刷新
		    setTimeout(()=>{
				uni.stopPullDownRefresh()
				that.top_height=that.padding_height;
				if(that.show_page==1){
					that.scroll_height="auto"
					that.banners=[]
					that.get_banner_list()
					that.jobs=[]
					that.get_job_list()
				}else{
					that.teachers=[]
					that.get_teacher_list()
				}
			},800)
		},
		onPageScroll(e) {
			// console.log(e)
			if(this.show_page==1&&e.scrollTop>=0){
				// if(e.scrollTop>0){
				// 	this.scroll_height='0px'
				// }else{
				// 	this.scroll_height=this.banner_height+'px'
				// }
				this.scroll_height=(this.banner_height-e.scrollTop>0?this.banner_height-e.scrollTop:'0')+'px'
				this.scroll=this.banner_height-e.scrollTop>0?this.banner_height-e.scrollTop:'0'
			}
		},
		watch:{
			addressInfo(val){
				console.log(val,'地址');
			},
			show_page(val){
				this.currentPage=1;
				this.positionId=-1;
				this.positionChildId=-1;
				this.count=0;
				this.show_nav=false;
				this.get_user_location();
				// 修改tabbar
				if(val==1){
					uni.setTabBarItem({
					  index: 0,
					  text: '职位',
					  iconPath: '/static/tab1.png',
					  selectedIconPath: '/static/tab2.png'
					})
				}else{
					uni.setTabBarItem({
					  index: 0,
					  text: '老师',
					  iconPath: '/static/tab5.png',
					  selectedIconPath: '/static/tab6.png'
					})
				}
			}
		},
		// 触底
		onReachBottom() {
			var that=this;
			if(that.hasMoreData){
				if(that.show_page==1){
					that.get_job_list();
				}else{
					that.get_teacher_list();
				}
			}else{
				util.page_show_toast('没有更多了',1500)
			}
		},
		methods: {
			addressUpdate(data){
				// console.log('地址：' + JSON.stringify(data))
				this.address = data.title
				this.latitude= data.location.lat
				this.longitude= data.location.lng
				// 刷新页面
				this.currentPage=1;
				this.jobs=[];
				this.teachers=[];
				// 刷新页面
				this.get_address_sdk(data.location.lat,data.location.lng,2)
			},
			watch_height(){
				var that=this,count=that.count;
				if(!uni.getStorageSync("first")){
					return false;
				}
				const query = uni.createSelectorQuery().in(this);
				count++
				that.count=count
				if(that.show_page==1){
					query.select('#top1').boundingClientRect(data => {
						// console.log(data)
						// #ifdef APP-PLUS
						if(!data&&count<=5){
							that.watch_height()
							return false;
						}
						// #endif
						that.top_height=data.height+Math.floor(that.windowWidth/(750/20));
						that.padding_height=data.height+Math.floor(that.windowWidth/(750/20));
					}).exec();
					query.select('#banner').boundingClientRect(data => {
						// console.log(data)
						// #ifdef APP-PLUS
						if(!data&&count<=5){
							that.watch_height()
							return false;
						}
						// #endif
						
						that.banner_height=data.height;
						that.scroll=data.height;
					}).exec();
				}else{
					query.select('#top2').boundingClientRect(data => {
						// console.log(data)
						// #ifdef APP-PLUS
						if(!data&&count<=5){
							that.watch_height()
							return false;
						}
						// #endif
						that.top_height=data.height;
						that.padding_height=data.height;
					}).exec();
				}
			},
			// 跳转搜索
			nav_search(){
				uni.navigateTo({
					url: '../search/search?type='+this.show_page+'&city='+this.jobObjectCitys
				})
			},
			// 轮播
			swiperChange(e){
				this.current_index=e.detail.current
			},
			// 轮播跳转
			jump_view(index){
				var banners=this.banners,title=banners[index].title,appletPage=banners[index].appletPage,h5Link=banners[index].h5Link,adUrl=banners[index].adUrl;
				if(appletPage){
					if(appletPage.indexOf("http")>-1){
						uni.navigateTo({
							url: '../../mypage/webImage/webImage?title='+title+'&url='+appletPage+'&page='+adUrl
						})
					}else{
						uni.navigateTo({
							url: appletPage
						})
					}
				}
				if(h5Link){
					uni.navigateTo({
						url: '../../mypage/webView/webView?index=5'+'&url='+h5Link
					})
				}
			},
			// 切换(热门、附近)
			choose_nav(index){
				this.bar_index=index;
				this.sidx=index==0?"create_time":"distance",
				this.order=index==0?"desc":"asc",
				this.currentPage=1;
				this.show_nav=false;
				this.jobs=[];
				//
				this.get_job_list();
			},
			// 求职意向
			nav_object(){
				if(this.login){
					uni.navigateTo({
						url: '../jobObject/jobObject?type=1',
					});
				}else{
					uni.navigateTo({
						url: '../login/login',
					})
				}
			},
			// 筛选
			nav_screen(){
				if(this.login){
					uni.navigateTo({
						url: '../screening/screening?data='+JSON.stringify({"educat_index": this.educat_index,"exper_index": this.exper_index,"wage_index": this.wage_index,"prop_index": this.prop_index}),
					});
				}else{
					uni.navigateTo({
						url: '../login/login',
					})
				}
			},
			// 选择(职位、学历、经验、薪资)
			check_dem(index){
				this.check_index=index;
				if(this.show_mask){
					return false;
				}
				if(index==1){
					uni.navigateTo({
						url: '../jobType/jobType?&range='+this.isRange+'&id='+this.positionId+'&child_id='+this.positionChildId+'&status=1'
					})
				}else{
					this.show_mask=true;
					switch(index){
						case 2:
							this.screens=this.educats;
							this.screenIndex=this.educat_index;
							break;
						case 3:
							this.screens=this.expers;
							this.screenIndex=this.exper_index;
							break;
						case 4:
							this.screens=this.wages;
							this.screenIndex=this.wage_index;
							break;
					}
				}
			},
			// 关闭mask
			close_mask(){
				this.show_mask=false;
			},
			// 选择
			check_screen(index){
				this.screenIndex=index;
			},
			// 清除
			delete_screen(){
				var type=this.check_index;
				this.screenIndex=-2;
				switch(type){
					case 2:
						if(this.educat_index>-2){
							this.educat_index=-2;
							this.educat_id='';
							this.show_nav=false;
							this.currentPage=1;
							this.teachers=[];
							this.get_teacher_list();
						}
						break;
					case 3:
						if(this.exper_index>-2){
							this.exper_index=-2;
							this.yearMax='';
							this.yearMin='';
							this.show_nav=false;
							this.currentPage=1;
							this.teachers=[];
							this.get_teacher_list();
						}
						break;
					case 4:
						if(this.wage_index>-2){
							this.wage_index=-2;
							this.salaryRangeMax='';
							this.salaryRangeMin='';
							this.show_nav=false;
							this.currentPage=1;
							this.teachers=[];
							this.get_teacher_list();
						}
						break;
				}
				this.close_mask();
			},
			// 确定
			confirm_screen(index){
				var type=this.check_index;
				switch(type){
					case 2:
						if(this.educat_index!=index){
							this.educat_index=index;
							this.educat_id=index!=-1?this.educats[index].id:'';
							this.show_nav=false;
							this.currentPage=1;
							this.teachers=[];
							this.get_teacher_list();
						}
						break;
					case 3:
						if(this.exper_index!=index){
							this.exper_index=index;
							this.yearMax=index!=-1?this.expers[index].rangeMax:'';
							this.yearMin=index!=-1?this.expers[index].rangeMin:'';
							this.show_nav=false;
							this.currentPage=1;
							this.teachers=[];
							this.get_teacher_list();
						}
						break;
					case 4:
						if(this.wage_index!=index){
							this.wage_index=index;
							this.salaryRangeMax=index!=-1?this.wages[index].salaryRangeMax:'';
							this.salaryRangeMin=index!=-1?this.wages[index].salaryRangeMin:'';
							this.show_nav=false;
							this.currentPage=1;
							this.teachers=[];
							this.get_teacher_list();
						}
						break;
				}
				this.close_mask();
			},
			requestIosPermission(){
				var that=this;
				const isLocation = permision.judgeIosPermission("location")
				uni.setStorageSync("isLocation",isLocation?1:0)
				if(isLocation){
					that.get_user_location()
				}else {
					uni.showModal({
						title: '请允许使用位置权限',
						content: '位置权限将用于获取附近职位',
						success: function (res) {
							if (res.confirm) {
							   permision.gotoAppPermissionSetting();
							} else if (res.cancel) {
								util.page_show_toast('未获得位置授权，无法推荐职位',2000)
								setTimeout(()=>{
									// 请求数据
									that.watch_height();
									that.get_address_sdk(that.latitude,that.longitude,1)
								},1500)
							}
						}
					});
				}
			},
			async requestAndroidPermission() {
				// #ifdef APP-PLUS
				console.log(plus.runtime.appid);
				var that=this;
				var result = await permision.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION');
				var strStatus;
				uni.setStorageSync("isLocation",result)
				if (result == 1) {
					that.get_user_location();
				} else if (result == 0) {
					strStatus = '未获得位置授权';
					uni.showModal({
						title: '请允许使用位置权限',
						content: '位置权限将用于获取附近职位',
						success: function (res) {
							if (res.confirm) {
							   permision.gotoAppPermissionSetting();
							} else if (res.cancel) {
								util.page_show_toast('未获得位置授权，无法推荐职位',2000)
								setTimeout(()=>{
									// 请求数据
									that.watch_height();
									that.get_address_sdk(that.latitude,that.longitude,1)
								},1500)
							}
						}
					});
				} else {
					strStatus = '被永久拒绝位置权限';
					uni.showModal({
						title: '请允许使用位置权限',
						content: '位置权限将用于获取附近职位',
						success: function (res) {
							if (res.confirm) {
							   permision.gotoAppPermissionSetting();
							} else if (res.cancel) {
								uni.showToast({
									title: '未获得位置授权，无法推荐职位',
									icon: 'none',
									duration: 2000
								});
							}
						}
					});
				}
				// #endif
			},
			// 定位
			get_user_location(){
				// uni.showLoading({title:"加载中"})
				var that=this;
				uni.getLocation({
					type: 'gcj02',
					success:function (res) {
						that.latitude=res.latitude;
						that.longitude=res.longitude;
						// 请求数据
						that.watch_height();
						that.get_address_sdk(res.latitude,res.longitude,1)
					},
					fail: function(){
						// 请求数据
						that.watch_height();
						that.get_address_sdk(that.latitude,that.longitude,1)
					}
				})
			},
			//重新选择定位
			choose_location(){
				var that=this;
				// #ifdef MP-WEIXIN
				uni.getSetting({
					success: function (res) {
						// console.log(res)
						if(res.authSetting["scope.userLocation"]){
							that.change_location()
						}else{
							 // 重新授权
							 uni.openSetting({
								success:function(res){
									if (res.authSetting["scope.userLocation"]) {
										that.change_location()
									}
								}
							})
						}
					}
				})
				// #endif
				// #ifdef H5 || APP-PLUS
				that.change_location()
				// #endif
			},
			change_location(){
				var that=this;
				// #ifdef MP-WEIXIN || H5
				uni.chooseLocation({
					success:function (res) {
						// console.log(res)
						var latitude=res.latitude,longitude=res.longitude;
						that.address=res.name;
						that.latitude=latitude;
						that.longitude=longitude;
						that.currentPage=1;
						that.jobs=[];
						that.teachers=[];
						// 刷新页面
						that.get_address_sdk(latitude,longitude,2)
					},
					fail:function(res){
						console.log("---重新定位失败---")
					}
				})
				// #endif
				// #ifdef APP-PLUS
				uni.navigateTo({
					url:'../../mypage/searchAddress/index'
				})
				// #endif
			},
			// 腾讯sdk解析地址
			get_address_sdk(latitude,longitude,type){
			    var that=this;
			    var QQMapWX = new qqmapsdk({
					key: 'EVZBZ-2EPWR-JGZWX-WQCQ7-AAXUE-NKBLV' // key
			    });  
			    QQMapWX.reverseGeocoder({
					location: {
						latitude: latitude,
						longitude: longitude
					},
					success:function(res){
						// console.log(res)
						var info=res.result;
						if(type==1){that.address=info.address_component.street_number}
						info.ad_info.city_code=info.ad_info.city=="北京市"?'110100':info.ad_info.city=="天津市"?'120100':info.ad_info.city=="上海市"?'310100':info.ad_info.city=="重庆市"?'500100':info.ad_info.city_code.split(info.ad_info.nation_code)[1];
						info.ad_info.lat=latitude;
						info.ad_info.lng=longitude;
						info.ad_info.address=info.address;
						info.ad_info.town=info.address_reference.town.title;
						uni.setStorageSync('user_address', info.ad_info)
						that.user_address=info.ad_info;
						// 登录
						that.is_login();
						if(!uni.getStorageSync("token")){
							that.get_all_data()
						}
					},
					fail:function(res){
						// 登录
						that.is_login();
						if(!uni.getStorageSync("token")){
							that.get_all_data()
						}
						console.log("---地址解析失败---")
					}
			    })
			},
			//获取页面数据
			get_all_data(){
				this.currentPage=1;
				if(this.show_page==1){
					this.jobs=[]
					this.get_banner_list();
				}else{
					this.teachers=[]
					this.get_teacher_list();
					this.get_education_list();
					this.get_exper_list();
					this.get_salary_list();
				}
			},
			// banner
			get_banner_list(){
				uni.showLoading();
				var params={
					"provinces": this.user_address?this.user_address.province:'广东省',
					"citys": this.user_address?this.user_address.city:'佛山市',
					"showRange": 1,
					"typeId": 1,
					"enable": 1,
					"belongToPage": 3
				}
				home.get_banner_list(params).then(res=>{
					uni.hideLoading();
					var list=res.data.data;
					this.banners=list.length>0?list:[{imgUrl:"https://ossdev0.jiabala.com/mPbYPY8248ehE"}]
				})
			},
			// 职位列表
			get_job_list(){
				uni.showLoading();
				var params={
					"positionId": this.positionId>=0?this.positionId:'',
					"positionChildId": this.positionChildId>0?this.positionChildId:'',
					"currentPage": this.currentPage,
					"pageSize": this.pageSize,
					"minimumEducationId": this.minimumEducationId,
					"workExperienceId": this.workExperienceId,
					"salaryRangeMin": this.salaryRangeMin,
					"salaryRangeMax": this.salaryRangeMax,
					"positionNature": this.positionNature,
					"sidx": this.sidx,
					"order": this.order,
					"city": this.jobObjectCitys?this.jobObjectCitys:this.user_address.city_code,
					"lat": this.latitude,
					"lng": this.longitude
				};
				home.get_job_list(params).then(res=>{
					uni.hideLoading();
					var list=res.data.data.records;
					list.forEach((item)=>{
						item.space=item.distance>1000?(item.distance/1000).toFixed(2):item.distance;
						item.salary = item.salaryMin==0?"面议":`${item.salaryMin/1000}-${item.salaryMax/1000}k/月`
					})
					//
					var jobs=util.extend(this.jobs, list)
					if (list.length < this.pageSize) {
						this.jobs=jobs;
						this.hasMoreData=false;
					} else {
						this.jobs=jobs;
						this.hasMoreData=true;
						this.currentPage=this.currentPage+1;
					}
					if(list.length==0&&jobs.length==0){
						this.show_nav=true;
					}
				})
			},
			// 老师列表
			get_teacher_list(){
				uni.showLoading();
				var params={
					"currentPage": this.currentPage,
					"pageSize": this.pageSize,
					"positionId": this.positionId>=0?this.positionId:'',
					"positionName": this.job_name,
					"positionChildId": this.positionChildId>0?this.positionChildId:'',
					"intentionCityName": this.user_address?this.user_address.city.replace("市",""):'',
					"educationId": this.educat_id,
					"yearMax": this.yearMax||this.yearMax==0?this.yearMax:'',
					"yearMin": this.yearMin||this.yearMin==0?this.yearMin:'',
					"salaryRangeMax": this.salaryRangeMax,
					"salaryRangeMin": this.salaryRangeMin,
					"businessId": uni.getStorageSync("userIdentity")?uni.getStorageSync("userIdentity").businessId:''
				}
				home.get_teacher_list(params).then(res=>{
					uni.hideLoading();
					var list=res.data.data.records;
					list.forEach((item)=>{
						item.age=item.birthday?new Date().getFullYear()-new Date(item.birthday).getFullYear():'';
						item.workYear=item.joinWorkTime?new Date().getFullYear()-new Date(item.joinWorkTime).getFullYear():'';
						item.salary = item.salaryMin==0||!item.salaryMin?"面议":`${item.salaryMin/1000}-${item.salaryMax/1000}k/月`
						item.works.forEach((itm)=>{
							itm.start=util.formatTime1(new Date(itm.entryTime),1);
							itm.end=util.formatTime1(new Date(itm.quitTime),1)
						})
						if(item.works.length>0){
							item.maxIndex=util.getMaxIndex(item.works)
						}
					})
					//
					var teachers=util.extend(this.teachers, list)
					if (list.length < this.pageSize) {
						this.teachers=teachers;
						this.hasMoreData=false;
					} else {
						this.teachers=teachers;
						this.hasMoreData=true;
						this.currentPage=this.currentPage+1;
					}
					if(list.length==0&&teachers.length==0){
						this.show_nav=true;
					}
				})
			},
			// 学历列表
			get_education_list(){
				home.get_education_list().then(res=>{
					this.educats=res.data.data
				})
			},
			// 经验列表
			get_exper_list(){
				home.get_exper_list().then(res=>{
					this.expers=res.data.data;
				})
			},
			// 薪资列表
			get_salary_list(){
				home.get_salary_list().then(res=>{
					this.wages=res.data.data;
				})
			},
			// 判断是否登录
			is_login(){
				var that=this;
				config.is_login().then(res=>{
					if(!res.data.data){
						console.log("---token已失效---")
						wx.removeStorageSync('token');
						var wx_info=wx.getStorageSync('unionId'),login_info=wx.getStorageSync('login_info');
						if(wx_info){
							that.wx_login(wx_info);
						}
						if(login_info){
							that.login_by_password(login_info);
						}
						if(this.show_page==1){
							that.get_job_list();
						}
					}else{
						that.get_all_data();
						that.login=true;
						if(that.show_page==1){
							that.userinfo=uni.getStorageSync("userinfo")
							that.get_job_intention()
							// that.get_org_list();
						}
						console.log("---token未失效---")
					}
				})
			},
			// 微信登录获取token信息
			wx_login(wx_info){
			    var params={
					"unionId": wx_info.unionId,
					"openId": wx_info.openId,
					"bindType": "1",
					"thirdAppId": api.data.appId
			    };
			    config.wx_login(params).then(res=>{
			        var info=res.data.data;
			        this.login=true;
					this.userinfo=info.userinfo
			        wx.setStorageSync('userinfo', info.userInfo);
			        wx.setStorageSync('token', info.token);
					this.get_all_data();
					if(this.show_page==1){
						this.get_job_intention();
						// this.get_org_list();
					}
			    })     
			},
			// 账号登录获取token信息
			login_by_password(info){
			    var params={
			    	"phone":info.phone,
					"password":info.password
			    };
			    config.login_by_password(params).then(res=>{
			        var info=res.data.data;
			        this.login=true;
					this.userinfo=info.userinfo
			        wx.setStorageSync('userinfo', info.userInfo);
			        wx.setStorageSync('token', info.token);
					this.get_all_data();
					if(this.show_page==1){
						this.get_job_intention();
						// this.get_org_list();
					}
			    })
			},
			// 求职意向
			get_job_intention(){
				var params={
					id: this.userinfo.id
				}
				home.get_job_intention(params).then(res=>{
					var info=res.data.data;
					if(info){
						this.jobObjectCitys=info?info.intentionCityCode:'';
						this.positionId=info.positionId
						this.positionChildId=info.positionChildId
					}
					//
					this.get_job_list();
				})
			},
			// 是否有认证机构
			get_org_list(){
				var params={
					"phone": uni.getStorageSync("userinfo").phone
				}
				config.get_org_list(params).then(res=>{
					var list=res.data.data;
					if(list&&list.length>0){
						var len=list.length;
						if(list[len-1].status==1){
							uni.reLaunch({
								url: '/pages/mechVerify/mechVerify?type=3'
							})
						}else if(list[len-1].status==4){
							uni.reLaunch({
								url: '/pages/mechVerify/mechVerify?type=1'+'&id='+list[len-1].businessId
							})
						}
					}
				})
			},
		},
		components: {
			jobItem: JobItem,
			topBar: TopBar,
			teacherItem: TeacherItem,
			screen: Screen,
			checkDem: CheckDem
		},
	}
</script>

<style lang="scss">
	page{
		background: #f7f6f9;
		.content{
			width: 100%;
			.page_teacher{
				width: 100%;
				.top_wrap{
					position: fixed;
					top: 0;
					left: 0;
					width: 100%;
					z-index: 999;
					background: #fff;
					.top_box{
						position: relative;
						.top_bg_box{
							position: absolute;
							top: 0;
							left: 0;
							width: 100%;
							z-index: 1;
							.top_bg{
								width:100%;
								height: 330rpx;  
								position: relative;  
								overflow: hidden;
								z-index: 100;
								&::after{
									display:block;
									content: ' ';
									width: 120%;
									height: 330rpx;
									position: absolute;
									left: -10%;
									top:0;
									z-index: -1;
									border-radius: 0 0 50% 50%;
									background:linear-gradient(180deg,rgba(91,173,255,1) 0%,rgba(91,144,255,1) 100%);
								}
							}
							.top_bg_height{
								height: 260rpx;
							}
							.top_bg_wrap{
								padding-top: 24px;
								&::after{
									padding-top: 24px;
								}
							}
						}
						.top_bar_wrap{
							position: relative;
							width: 100%;
							z-index: 200;
							// padding-bottom: 16rpx;
							.banner_box{
								padding: 0 32rpx;
								margin-top: 20rpx;
								border-radius: 16rpx;
								overflow: hidden;
								transform: translateY(0);
								transition: height 0.05s linear;
								.swiper{
									width: 100%;
									height: 200rpx;
									border-radius: 16rpx;
									overflow:hidden;
									transform: translateY(0);
									.item{
										width: 100%;
										height: 200rpx;
										border-radius: 16rpx;
										overflow:hidden;
										.img{
											width: 100%;
											height: 200rpx;
										}
									}
								}
								.indication{
									width: 400rpx;
									height: 8rpx;
									padding-top: 20rpx;
									margin: 0 auto;
									display:flex;
									flex-direction:row;
									align-items:center;
									justify-content:center;
								}
								.spot{
									width: 8rpx;
									height: 8rpx;
									border-radius: 50%;
									margin-right: 8rpx;
									background: #EAEDF0;
									transition: all 0.3s;
								}
								.active{
									width: 20rpx;
									height: 8rpx;
									border-radius: 4rpx;
									background: #5B90FF;
								}
							}
							.nav_bar{
								display: flex;
								flex-direction: row;
								align-items: center;
								padding: 36rpx 32rpx 16rpx 32rpx;
								background: #fff;
								.bar_wrap{
									flex: 1;
									display: flex;
									flex-direction: row;
									align-items: center;
									.bar_img{
										width: 130rpx;
										height: 62rpx;
										margin-right: 62rpx;
									}
									.bar_text{
										height: 50rpx;
										font-size: 36rpx;
										font-weight:600;
										line-height: 50rpx;
										color:rgba(121,133,148,0.5);
									}
									.active{
										color: #5B90FF;
									}
								}
								.btn_wrap{
									display: flex;
									flex-direction: row;
									.btn{
										display: flex;
										flex-direction: row;
										align-items: center;
										padding: 10rpx 20rpx;
										background: rgba(246,247,249,1);
										border-radius: 8rpx;
										&:first-child{
											margin-right: 20rpx;
										}
										.text{
											height: 34rpx;
											font-size: 24rpx;
											font-weight: 400;
											line-height: 34rpx;
											color:rgba(121,133,148,1);
											margin-right: 4rpx;
										}
										.icon{
											width: 20rpx;
											height: 20rpx;
										}
									}
								}
							}
							.nav_pad{
								padding: 16rpx 32rpx;
							}
						}
					}
				}
				.top_wrap_posit{
					position: relative;
				}
				.job_list{
					width: 100%;
				}
			}
			.page_mech{
				width: 100%;
				.top_wrap{
					position: fixed;
					top: 0;
					left: 0;
					width: 100%;
					z-index: 999;
					.top_box{
						width: 100%;
						background:linear-gradient(180deg,rgba(91,173,255,1) 0%,rgba(91,144,255,1) 100%);
						padding-bottom: 20rpx;
					}
				}
				.top_wrap_posit{
					position: relative;
				}
				.teach_list{
					width: 100%;
				}
			}
			.no_cont{
				width: 520rpx;
				margin: 90rpx auto 0 auto;
				.no_box{
					width: 100%;
					height: 520rpx;
					box-sizing: border-box;
					padding-top: 360rpx;
					background: url("https://ossdev0.jiabala.com/nUNzhnyPqbzlP") no-repeat 0 0/100% 100%;
					margin-bottom: 24rpx;
					.title{
						text-align: center;
						height: 50rpx;
						font-size: 32rpx;
						font-weight:400;
						line-height: 50rpx;
						color: #3F4A58;
						margin-bottom: 8rpx;
					}
					.text{
						text-align: center;
						height: 40rpx;
						font-size: 28rpx;
						font-weight:400;
						line-height: 40rpx;
						color: #798594;
					}
				}
				.nav_btn{
					width: 272rpx;
					margin: auto;
					height: 88rpx;
					background: #5B90FF;
					text-align: center;
					font-size: 30rpx;
					font-weight: 400;
					line-height: 88rpx;
					color:#fff;
					letter-spacing:2rpx;
					border-radius: 16rpx;
				}
			}
		}
	}
</style>
